﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Microsoft.VisualBasic.ApplicationServices;

namespace SynoManager.GUI
{
    class Program : WindowsFormsApplicationBase
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Program prog = new Program();
            mainForm = new MainForm();
            prog.MainForm = mainForm;
            prog.Run(args);
        }

        private static MainForm mainForm = null;

        public Program()
        {
            this.IsSingleInstance = true;
        }

        protected override bool OnStartup(StartupEventArgs eventArgs)
        {
            bool result = base.OnStartup(eventArgs);

            mainForm.Startup(eventArgs.CommandLine);

            return result;
        }

        protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
        {
            base.OnStartupNextInstance(eventArgs);

            // Parse eventArgs in mainform
            mainForm.Startup(eventArgs.CommandLine);
            eventArgs.BringToForeground = true;
        }
    }
}
